package cate.game.db.facade;

import cate.game.GameBody;
import cate.game.db.mongo.kv.KvMongo;
import org.apache.commons.lang3.StringUtils;

public class GameKvDaoFacade extends KvDaoFacade {

    private GameBody game;

    public GameKvDaoFacade(GameBody game) {
        super(game.facilities.getMongo().kv);
        this.game = game;
    }

    @Override
    public void save(KvMongo kv) {
        if(kv == null) {
            return;
        }
        kv.srvId = this.game.config.srvId;
        if(StringUtils.isNotBlank(kv.getKeyPrefix())) {
            kv.key = kv.getKeyPrefix() + "-" + kv.srvId;
        }
        super.save(kv);
    }
}
